"""
@title(TenX腾晓2024年11月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
"""


class TenXClass:
    def __init__(self):
        self.name = "黄子晴"
        self.id = "3224002027"

    @staticmethod
    def question1(n: int) -> list[str]:
        def ten_to_4(n):
            four_str = ""
            while n > 0:
                four_str = str(n % 4) + four_str
                n = n // 4
            return four_str

        result = []
        for i in range(1, n + 1):
            f4 = ten_to_4(i)
            result.append(f4)
        return result

    @staticmethod
    def question2() -> tuple[int, int, int]:
        result = []
        for x in range(0, 21):
            for y in range(0, 34):
                z = 100 - x - y
                if z % 3 == 0 and 5 * x + 3 * y + z // 3 == 100:
                    result.append((x, y, z))
        return result

    @staticmethod
    def question3(equipment: list[str], prop: list[str], material: list[str], items: list[str]) -> dict[str, list[str]]:
        print(equipment, prop, material, items)  # 打印，防止IDE警告
        lei = {
            "equipment": [],
            "prop": [],
            "material": []
        }

        for item in items:
            if item in equipment:
                lei["equipment"].append(item)
            elif item in prop:
                lei["prop"].append(item)
            elif item in material:
                lei["material"].append(item)

        return lei

    @staticmethod
    def question4(item_values: dict[str, int], items: list[str]) -> tuple[list[str], int]:
        big_items = []
        for item in items:
            if len(big_items) < 3:
                # values（字典），存储物品及价值
                big_items.append((item, item_values[item]))
            else:
                # 将big_items列表中第一个元素的第二个值（即第一个物品的价值）赋值给min_value，找小
                min_value = big_items[0][1]
                # 初始化为0，假设第一个最小
                min = 0
                # 从第二个开始搜查
                for i in range(1, len(big_items)):
                    # 查看第i个物品的价格
                    if big_items[i][1] < min_value:
                        # 更新最小值
                        min_value = big_items[i][1]
                        min = i
                # 替换
                if item_values[item] > min_value:
                    big_items[min] = (item, item_values[item])
        # sum求总和
        total = sum(item[1] for item in big_items)
        return [item[0] for item in big_items], total

    @staticmethod
    def question5(matrix: list[list[int]]) -> list[tuple[int, int]]:
        zero = []
        for i in range(len(matrix)):
            for j in range(len(matrix[i])):
                if matrix[i][j] == 0:
                    zero.append((i + 1, j + 1))
        return zero
